<template>
  <div>
    <el-row>
      <el-col :span="24">
        <div class="grid-content bg-purple-dark">
          <h2>修改密码</h2>
        </div></el-col>
    </el-row>

    <el-row >
      <el-col style="margin-left: 41.6%; margin-top: 5%" :span="4">
        <el-input
            placeholder="请输入旧密码"
            v-model="oldPwd"
            clearable
            show-password>
        </el-input>
      </el-col>
    </el-row>

    <el-row >
      <el-col style="margin-left: 41.6%; margin-top: 3%" :span="4">
        <el-input
            placeholder="请输入新密码"
            v-model="newPwd"
            clearable
            show-password>
        </el-input>
      </el-col>
    </el-row>

    <el-row >
      <el-col style="margin-left: 41.6%; margin-top: 3%" :span="4">
        <el-input
            placeholder="请再次确认新密码"
            v-model="newPwd2"
            clearable
            show-password>
        </el-input>
      </el-col>
    </el-row>

    <el-row >
      <el-col style="margin-left: 41.6%; margin-top: 3%" :span="4">
        <el-button type="primary" icon="el-icon-edit" @click="update">修改</el-button>
      </el-col>
    </el-row>

  </div>
</template>

<script>
export default {
  name: "UpdatePwd",
  data(){
    return{
      searchShow:false,
      id:'',
      oldPwd:'',
      newPwd:'',
      newPwd2:''
    }
  },
  mounted(){
    this.id = JSON.parse(sessionStorage.getItem("loginUser")).id
  },
  methods:{
    update(){
      let param = new FormData();
      param.append('id',this.id);
      param.append('oldPwd',this.oldPwd);
      param.append('newPwd',this.newPwd);
      param.append('newPwd2',this.newPwd2);
      this.$axios.put('/api/userInfo/updatePwd',param).then(
          r=>{
            let obj = r.data
            if(obj.code === 0){
              this.$message.success(obj.info)
              this.oldPwd=''
              this.newPwd=''
              this.newPwd2=''
               this.$router.push("Login")
              // this.$axios.put('/api/login/')
              sessionStorage.clear()
            }else {
              this.$message.error(obj.info)
            }
          }
      )
    }
  }
}
</script>
<style scoped>
</style>










